package com.my.hotel.controller;


import com.alibaba.druid.sql.visitor.functions.Char;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.my.hotel.entity.Eva;
import com.my.hotel.entity.Hd;
import com.my.hotel.service.RoleService;
import com.my.hotel.service.TbEvaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.sql.Array;
import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/TbEva")
public class TbEvaController {
@Autowired
private TbEvaService tbEvaService;
    @RequestMapping("/tbEvaPage")
    public String getPage(Model model, Integer pageNo,String app_status){
      if(pageNo==null||pageNo==0){
            pageNo=1;
        }
        if(app_status==null||app_status.equals("")){
            app_status="";
        }
        PageHelper.startPage(pageNo,10);
        List<Eva> list =tbEvaService.getList(app_status);
        PageInfo<Eva> page = new PageInfo<Eva>(list);
        if (app_status.equals("")){
            app_status="3";
        }
        model.addAttribute("app_status",app_status);
        model.addAttribute("pageNo",pageNo);
        model.addAttribute("page",page);
        return "evaPage";
    }

    @RequestMapping("/delEva")
    public String delEva(int id,Model model){
        tbEvaService.delEva(id);
        return getPage(model);
    }

    @RequestMapping("/updEva")
    public String updEva(int id,Model model){
        tbEvaService.updEva(id);
        return getPage(model);
    }

    @RequestMapping("/delAllTbEva")
    public String delAllTbEva(String ids, Model model){
        tbEvaService.delAllEva(ids);
        return getPage(model);
    }

    @RequestMapping("/updateAllEva")
    public String updateAllEva(String ids, Model model){
        tbEvaService.updateAllEva(ids);
        return getPage(model);
    }

    public String getPage(Model model){
        return getPage(model,1,"");
    }

}
